package com.example.administrator.exkotlin.utils

import android.content.Context
import android.widget.Toast
import java.lang.RuntimeException

/**
 * Author by lp,on 2020/8/28/028,15:17.
 * 常用的工具类
 */

//比较系列数据大小
fun <T : Comparable<T>> max(vararg nums: T): T {
    if (nums.isEmpty()) throw RuntimeException("参数不能为空")
    var maxNum = nums[0]
    for (num in nums) {
        if (maxNum < num) {
            maxNum = num
        }
    }
    return maxNum
}


//弹出提示框
fun String.showToast(context: Context,duration:Int=Toast.LENGTH_SHORT) {
    Toast.makeText(context, this, duration).show()
}
